# 🤖 Full Agent + Streamlit + LangGraph - Copilot Installation Prompt

Use the following prompt with GitHub Copilot or any AI coding assistant to install and configure this project.

---

## 📋 Prompt for Copilot

```
I need help installing and running the "Full Agent + Streamlit + LangGraph" project. This is a production-ready AI chatbot using LangGraph for cyclic supervisor graph orchestration, with RAG capabilities, moderation layers, and guardrails.

## Project Requirements

### System Dependencies
- **Python**: Version 3.11 or 3.12 (required)
- **Ollama**: Local LLM runtime (required)
- **Graphviz**: For LangGraph visualization (required for visualization features)

### Key Python Packages (from requirements.txt)
- streamlit==1.53.1
- langchain==1.1.3
- langchain-ollama==1.0.1
- langgraph==1.0.7
- langgraph-prebuilt==1.0.7
- faiss-cpu==1.13.2
- sentence-transformers==5.2.2
- torch>=2.0.0
- pdfplumber==0.11.9
- PyPDF2==3.0.1


## Installation Steps

### Step 1: Install System Dependencies

**Windows (PowerShell as Administrator):**
Run the script at: setup/windows/install.ps1
This will install:
- Microsoft Visual C++ Redistributable 2015+
- Ollama (via winget)
- Graphviz (via winget)

**macOS (Terminal):**
Run the script at: setup/mac/install.sh
This will install via Homebrew:
- Homebrew (if not installed)
- Graphviz
- Ollama

### Step 2: Create Python Virtual Environment

**Windows:**
python -m venv .venv
.\.venv\Scripts\activate

**macOS/Linux:**
python3 -m venv .venv
source .venv/bin/activate

### Step 3: Install Python Dependencies
pip install --upgrade pip
pip install -r requirements.txt

### Step 4: Configure Ollama
ollama serve
ollama pull llama3.1  # Recommended for tool calling support

### Step 5: Generate FAISS Vector Database (if PDFs exist)
python src/rag/generate_vector_db.py

### Step 6: Run the Application
streamlit run ui.py


## Project Structure
Full Agent + streamlit + langgraph/
├── ui.py                      # Main Streamlit entry point
├── setup/                     # Installation scripts
│   ├── windows/
│   │   ├── install.ps1        # Windows system setup
│   │   └── fix_pytorch_cuda.bat # GPU acceleration fix
│   └── mac/
│       └── install.sh         # macOS system setup
├── requirements.txt           # Python dependencies
├── docker-run.sh              # Docker helper script
├── Dockerfile                 # Docker configuration
├── docker-compose.yml         # Docker orchestration
├── config/
│   └── model_config.yaml      # LLM configuration
├── src/
│   ├── llm/                   # LLM clients and agent factory
│   │   ├── agent_factory.py   # LangGraph agent creation
│   │   └── ollama_client.py   # Ollama integration
│   ├── rag/                   # RAG with FAISS
│   │   ├── retriever.py       # Document retrieval
│   │   ├── tools.py           # RAG search tool
│   │   └── generate_vector_db.py
│   ├── moderation/            # Security layer
│   │   └── manager.py         # Toxicity, injection, PII, DLP
│   ├── guardrails/            # Quality validators
│   │   └── validators.py      # Citations, tone check
│   └── tools/                 # Agent tools
│       └── basic_tools.py     # Calculate, summarize
├── tabs/                      # Streamlit UI tabs
│   ├── chat_tab.py
│   ├── setup_tab.py
│   ├── rag_tab.py
│   ├── visualization_tab.py   # LangGraph execution traces
│   ├── quality_validation_tab.py
│   └── help_tab.py
├── tests/                     # Unit tests
│   └── unit/
│       └── test_moderation.py
└── data/
    ├── docs/books/            # PDF documents for RAG
    └── embeddings/            # FAISS index (generated)


## Key Differences from LangChain Version
- Uses **LangGraph** for cyclic supervisor graph orchestration
- Multi-step reasoning with state management
- Enhanced execution trace visualization
- Checkpointing support via langgraph-checkpoint


## Expected Output
After successful installation, the application should:
1. Open at http://localhost:8501
2. Show a chat interface with multiple tabs
3. Connect to Ollama for LLM inference
4. Display LangGraph execution traces in the Visualization tab
5. Support RAG search if documents are indexed


## Troubleshooting
- If Ollama connection fails: Ensure `ollama serve` is running
- If FAISS not found: Run `python src/rag/generate_vector_db.py`
- If Graphviz visualization fails: Ensure Graphviz is installed and in PATH
- If torch fails: On Windows with NVIDIA GPU, run `setup\windows\fix_pytorch_cuda.bat`
- If tool calling fails: Use llama3.1 model (supports function calling)
```

---

## 🎯 Quick Commands Summary

| Task | Command |
|------|---------|
| System setup (Windows) | `.\setup\windows\install.ps1` |
| System setup (macOS) | `./setup/mac/install.sh` |
| Create venv (Windows) | `python -m venv .venv && .\.venv\Scripts\activate` |
| Create venv (macOS) | `python3 -m venv .venv && source .venv/bin/activate` |
| Install dependencies | `pip install -r requirements.txt` |
| Start Ollama | `ollama serve` |
| Pull model | `ollama pull llama3.1` |
| Generate index | `python src/rag/generate_vector_db.py` |
| Run app | `streamlit run ui.py` |
| Docker run | `./docker-run.sh run` |

---

## 🐳 Docker Alternative (Recommended)

For a consistent environment, use Docker:

```bash
# Ensure Ollama is running on host
ollama serve
ollama pull llama3.1

# Run with Docker
chmod +x docker-run.sh
./docker-run.sh run

# OR use docker-compose
docker-compose up --build

# Access at http://localhost:8501
```
